<?xml version="1.0" encoding="UTF-8"?>
<project name="Jenkins-Drupal7" default="all" basedir=".">
  <property file="./php.properties"/>
  <property file="./build.properties"/>
  <target name="prepare" depends="clean">
    <mkdir dir="${dir.output}"/>
    <mkdir dir="${dir.tmp}"/>
  </target>

  <target name="clean">
    <delete dir="${dir.output}"/>
  </target>

  <target name="phpdepend">
    <exec command="${phing} _phpdepend" passthru="true"/>
  </target>
  <target name="_phpdepend">
    <mkdir dir="${phpdepend.output.xml.dir}"/>
    <mkdir dir="${phpdepend.output.html.dir}"/>
    <exec
      command="${phpdepend.exec} ${phpdepend.args}"
      dir="${project.basedir}"
      passthru="true"
    />
    <xslt
      file="${phpdepend.output.xml.file}"
      tofile="${phpdepend.output.html.file}"
      style="${phpdepend.style}"
    />
  </target>

  <target name="phpcs">
    <exec command="${phing} _phpcs" passthru="true"/>
  </target>
  <target name="_phpcs">
    <mkdir dir="${phpcs.output.xml.dir}"/>
    <mkdir dir="${phpcs.output.html.dir}"/>
    <exec
      command="${phpcs.exec} ${phpcs.args}"
      dir="${project.basedir}"
      passthru="true"
    />
    <xslt
      file="${phpcs.output.xml.file}"
      tofile="${phpcs.output.html.file}"
      style="${phpcs.style}"
    />
  </target>

  <target name="phpunit">
    <exec command="${phing} _phpunit" passthru="true"/>
  </target>
  <target name="_phpunit">
    <mkdir dir="${phpunit.output.xml.dir}"/>
    <mkdir dir="${phpunit.output.html.dir}"/>
    <exec
      command="${phpunit.exec} ${phpunit.args}"
      dir="${project.basedir}/test"
      passthru="true"
    />
    <xslt
      file="${phpunit.output.xml.file}"
      tofile="${junit.output.xml.file}"
      style="${junit.style}"
    />
  </target>

  <target name="phpmd">
    <exec command="${phing} _phpmd" passthru="true"/>
  </target>
  <target name="_phpmd">
    <mkdir dir="${phpmd.output.xml.dir}"/>
    <mkdir dir="${phpmd.output.html.dir}"/>
    <exec
      command="${phpmd.exec} ${phpmd.args}"
      dir="${project.basedir}"
      passthru="true"
    />
    <xslt
      file="${phpmd.output.xml.file}"
      tofile="${phpmd.output.html.file}"
      style="${phpmd.style}"
    />
  </target>

  <target name="phpcpd">
    <exec command="${phing} _phpcpd" passthru="true"/>
  </target>
  <target name="_phpcpd">
    <mkdir dir="${phpcpd.output.xml.dir}"/>
    <mkdir dir="${phpcpd.output.html.dir}"/>
    <exec
      command="${phpcpd.exec} ${phpcpd.args}"
      dir="${project.basedir}"
      passthru="true"
    />
    <xslt
      file="${phpcpd.output.xml.file}"
      tofile="${phpcpd.output.html.file}"
      style="${phpcpd.style}"
    />
  </target>

  <target name="phpdoc">
    <exec command="${phing} _phpdoc" passthru="true"/>
  </target>
  <target name="_phpdoc">
    <mkdir dir="${phpdoc.output.html.dir}"/>
    <exec
      command="${phpdoc.exec} ${phpdoc.args}"
      dir="${project.basedir}"
      passthru="true"
    />
  </target>

  <target name="phploc">
    <exec command="${phing} _phploc" passthru="true"/>
  </target>
  <target name="_phploc">
    <mkdir dir="${phploc.output.html.dir}"/>
    <exec
      command="${phploc.exec} ${phploc.args} > ${phploc.output.html.file}"
      dir="${project.basedir}"
      passthru="true"
    />
  </target>

  <target name="package">
    <exec command="${phing} _package" passthru="true"/>
  </target>
  <target name="_package">
    <mkdir dir="${package.output.dir}"/>
    <exec
      command="${pear.exec} channel-discover ${pear.channel}"
      dir="${project.basedir}" passthru="true"
    />
    <exec
      command="${genphar.exec} ${genphar.args}"
      dir="${project.basedir}"
      passthru="true"
    />
    <exec
      command="${genpear.exec}" dir="${project.basedir}" passthru="true"
      output="${dir.output}/package.xml"
    />
    <copy file="${dir.output}/package.xml" tofile="${dir.src}/package.xml" />
    <exec
      command="${pear.exec} package" dir="${dir.src}" passthru="true"
    />
    <delete file="${dir.src}/package.xml" />
    <move file="${dir.src}/${peartgz}" tofile="${dir.output}/${peartgz}" overwrite="true"/>
  </target>

  <target name="install-dependencies">
   <mkdir dir="/var/www/phpteam/Jekins-Vendor"/>
   <exec
   command="${defaultpear.bin} config-create ${dir.vendor} ${dir.vendor}/.pearrc"
      passthru="true"
    />
    <exec
      command="${defaultpear.exec} config-set php_bin ${php.bin}"
      passthru="true"
    />
    <exec
      command="${defaultpear.exec} config-set php_dir ${dir.vendor}/php"
      passthru="true"
    />
    <exec
      command="${defaultpear.exec} config-set bin_dir ${dir.vendor}/bin"
      passthru="true"
    />
    <exec
      command="${defaultpear.exec} config-set cache_dir ${dir.vendor}/cache"
      passthru="true"
    />
    <exec
      command="${defaultpear.exec} config-set cfg_dir ${dir.vendor}/cfg"
      passthru="true"
    />
    <exec
      command="${defaultpear.exec} config-set data_dir ${dir.vendor}/data"
      passthru="true"
    />
    <exec
      command="${defaultpear.exec} config-set download_dir ${dir.vendor}/download"
      passthru="true"
    />
    <exec
      command="${defaultpear.exec} config-set temp_dir ${dir.vendor}/tmp"
      passthru="true"
    />
    <exec
      command="${defaultpear.exec} config-set doc_dir ${dir.vendor}/doc"
      passthru="true"
    />
    <exec
      command="${defaultpear.exec} config-set test_dir ${dir.vendor}/test"
      passthru="true"
    />
    <exec
      command="${defaultpear.exec} config-set www_dir ${dir.vendor}/www"
      passthru="true"
    />
    <exec
      command="${defaultpear.exec} config-set auto_discover 1"
      passthru="true"
    />
   <exec
   command="${defaultpear.exec} install pear"
   passthru="true"
   />
   <exec
      command="${pear.exec} install --alldeps pear.phpunit.de/PHPUnit"
      passthru="true"
    />
    <exec
      command="${pear.exec} install --alldeps phpunit/phploc"
      passthru="true"
    />
    <exec
      command="${pear.exec} install --alldeps pear.docblox-project.org/DocBlox"
      passthru="true"
    />
    <exec
      command="${pear.exec} install --alldeps pear.pdepend.org/PHP_Depend-beta"
      passthru="true"
    />
    <exec
      command="${pear.exec} install --alldeps pear.phpmd.org/PHP_PMD"
      passthru="true"
    />
    <exec
      command="${pear.exec} install --alldeps pear.phpunit.de/phpcpd"
      passthru="true"
    />
    <exec
      command="${pear.exec} install --alldeps PHP_CodeSniffer"
      passthru="true"
    />
    <exec
      command="${pear.exec} install --alldeps pear.phing.info/phing"
      passthru="true"
    />
  </target>

  <target name="clean-dependencies">
    <delete dir="${dir.vendor}"/>
  </target>

  <target name="all" depends="clean, prepare, package, report"/>
  <target name="build" depends="prepare, test"/>
  <target name="test" depends="prepare, phpunit"/>
  <target name="report" depends="build, phploc, phpdoc, phpdepend, phpcs, phpmd, phpcpd"/>
  <target name="sutrix" depends="clean,prepare,phpcs,phpcpd,phpdepend,phpmd" />
</project>
